<template>
    <div class="box">
        <iframe width="100%" height="100%" frameborder="no" scrolling="no" class="bg" src="loading.html"></iframe>
    </div>
</template>

<script>
    export default {
        name: "Home",
        data(){
            return {
                target: ""
            }
        },
        mounted() {
            var check = new Promise((resolve) => {
                $.get("/login/checkLogin")
                    .then(r => {
                    if(r.success && r.data){
                        this.target = "index";
                    } else {
                        this.target = "login";
                    }
                    resolve();
                }).fail(e => {
                    this.target = "login";
                    resolve();
                });
            });
            var wait = new Promise((r) => {
                setTimeout(() =>{
                    r();
                },800);
            });
            Promise.all([check,wait]).then(e => {
                this.$router.push(this.target)
            });
        }
    }
</script>

<style scoped>
    .box{
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    .bg{
        width: 100vw;
        height: 100vh;
    }
</style>